package cn.darksoul3.spark.operator

import org.apache.spark.{SparkConf, SparkContext}

object MaxMin {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("ForeachPartition").setMaster("local[*]")

    val sc = new SparkContext(conf)

    val numbers = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7), numSlices = 2)
    val max = numbers.reduce((x, y) => Math.max(x, y))
    val min = numbers.reduce((x, y) => Math.min(x, y))

    println(s"max $max min $min")

    sc.stop()

  }
}
